/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.etecmatao.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author admin
 */
@Entity
@Table(name = "noticias")
@NamedQueries({
    @NamedQuery(name = "Noticias.findAll", query = "SELECT n FROM Noticias n"),
    @NamedQuery(name = "Noticias.findByIdNoticias", query = "SELECT n FROM Noticias n WHERE n.idNoticias = :idNoticias"),
    @NamedQuery(name = "Noticias.findByTitulo", query = "SELECT n FROM Noticias n WHERE n.titulo = :titulo"),
    @NamedQuery(name = "Noticias.findByData", query = "SELECT n FROM Noticias n WHERE n.data = :data"),
    @NamedQuery(name = "Noticias.findByStatus", query = "SELECT n FROM Noticias n WHERE n.status = :status")})
public class Noticias implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Noticias")
    private Integer idNoticias;
    @Basic(optional = false)
    @Column(name = "titulo")
    private String titulo;
    @Basic(optional = false)
    @Lob
    @Column(name = "conteudo")
    private byte[] conteudo;
    @Basic(optional = false)
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    @Basic(optional = false)
    @Column(name = "status")
    private String status;
    @JoinColumn(name = "email", referencedColumnName = "email")
    @ManyToOne(optional = false)
    private Login login;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "noticias")
    private List<FotosNoticias> fotosNoticiasList;

    public Noticias() {
    }

    public Noticias(Integer idNoticias) {
        this.idNoticias = idNoticias;
    }

    public Noticias(Integer idNoticias, String titulo, byte[] conteudo, Date data, String status) {
        this.idNoticias = idNoticias;
        this.titulo = titulo;
        this.conteudo = conteudo;
        this.data = data;
        this.status = status;
    }

    public Integer getIdNoticias() {
        return idNoticias;
    }

    public void setIdNoticias(Integer idNoticias) {
        this.idNoticias = idNoticias;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public byte[] getConteudo() {
        return conteudo;
    }

    public void setConteudo(byte[] conteudo) {
        this.conteudo = conteudo;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Login getLogin() {
        return login;
    }

    public void setLogin(Login login) {
        this.login = login;
    }

    public List<FotosNoticias> getFotosNoticiasList() {
        return fotosNoticiasList;
    }

    public void setFotosNoticiasList(List<FotosNoticias> fotosNoticiasList) {
        this.fotosNoticiasList = fotosNoticiasList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idNoticias != null ? idNoticias.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Noticias)) {
            return false;
        }
        Noticias other = (Noticias) object;
        if ((this.idNoticias == null && other.idNoticias != null) || (this.idNoticias != null && !this.idNoticias.equals(other.idNoticias))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "admin.model.Noticias[idNoticias=" + idNoticias + "]";
    }

}
